package com.eascs.ticket.ticket.controller;

import java.util.List;

import com.eascs.common.doc.excel.RowWriteHandler;
import com.eascs.common.doc.excel.WriteCell;
import com.eascs.site.page.PaginationInfo;

public class ExportExcelRowWriteHandlerImpl implements RowWriteHandler {

	private final PaginationInfo paginationInfo;

	public ExportExcelRowWriteHandlerImpl(PaginationInfo paginationInfo) {
		super();
		this.paginationInfo = paginationInfo;
	}

	int rowIndex = 0;
	int cols = 17;

	@Override
	public int getColumnIndex() {
		return 0;
	}

	@Override
	public int getColumnNumber() {
		return cols;
	}

	@Override
	public int getRowIndex() {
		return 1;
	}

	@Override
	public int getSheetIndex() {
		return 0;
	}

	@Override
	public int[] getTotalCols() {
		return null;
	}

	@Override
	public List<WriteCell> getWriteCells() {
		return null;
	}

	@Override
	public Object[] nextRowDatas() {
		if (rowIndex >= paginationInfo.getPageResult().getData().size())
			return null;
		List<Object[]> data = paginationInfo.getPageResult().getData();
		Object[] datas = data.get(rowIndex++);
		Object[] objs = new Object[cols];
		for (int i = 0; i < objs.length; i++) {
			objs[i] = datas[i + 1];
		}
		return objs;
	}
}